<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/tags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="description" content="">
    <%@include file="/common/style.jsp" %>
    <link rel="stylesheet" type="text/css" href="${static_url}/ui/app/assets/css/uc.css">

    <%@include file="/common/javascript.jsp" %>
    <%@include file="/common/js/niceValidator.jsp"%>


</head>
<body class="wide">
<!-- 头部 -->
<%@include file="/common/myHeader.jsp" %>
<!-- /头部 -->

<!-- 主体 -->
<div style="border-top: solid 1px #dcdcdc;" class="mb10"></div>
<div class="g">
    <!--面包屑 -->
    <%--<div class="breadcrumb-area"><a href="/" title="首页">首页</a>&nbsp;&nbsp;\&nbsp;&nbsp;<em
            id="personCenter"><span>我的商城</span></em><em id="pathPoint"></em><span id="pathTitle"></span></div>--%>
</div>
<div class="h20"></div>
<div class="g">
    <div class="fr u-4-5"><!-- 20141212-栏目-start -->
        <div class="section-header">
            <div class="fl">
                <h2><span>新建商品<c:if test="${goods!=null}">(模版导入<a href="${ctx}/my/seller/myTemplate.htm"> >></a>)</c:if></span></h2>
            </div>
        </div>
        <div class="h20"></div>
        <div class="myAddress-edit" id="myAddress-edit">
            <div class="form-edit-panels" id="form-edit-panels">
                <form id="myGoods" action="${ctx}/my/seller/saveGoods.htm" method="post" data-validator-option="{stopOnError:false, timely:true}">

                    <c:if test="${ishop.role=='seller'}">
                    <input type="hidden" name="sellerId" value="${ishop.id}"/>
                    </c:if>
                    <c:if test="${ishop.role=='xiaoer'}">
                        <input type="hidden" name="sellerId" value="${ishop.sellerId}"/>
                        <input type="hidden" name="xiaoerId" value="${ishop.id}"/>
                    </c:if>
                    <div class="form-edit-table">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tbody>

                            <tr>
                                <th><span class="required">*</span><label for="name">商品名称：</label></th>
                                <td>
                                    <input  type="text" name="name" id="name" class="text w600"
                                            value="${goods.name}"
                                           data-rule="required;length[4~100];"
                                           data-msg-required="请输入商品名称"
                                           data-ok=""
                                           data-target="#name-msg">
                                    <label id="name-msg"></label>
                                </td>
                            </tr>
                            <tr>
                                <th><span class="required">*</span><label>是否上架：</label></th>
                                <td>
                                    <select name="publishState" id="publishState" class="ec_linkSelect"
                                            data-rule="required;"
                                            data-msg-required="请选择是否上架"
                                            data-ok=""
                                            data-target="#publishState-msg">
                                        <option value="0">未上架</option>
                                        <option value="1">上架</option>
                                    </select>
                                    <label id="publishState-msg"></label>
                                </td>
                            </tr>
                            <tr>
                                <th><span class="required">*</span><label for="dictionaryId">商品分类：</label></th>
                                <td>
                                    <select name="dictionaryId" id="dictionaryId" class="ec_linkSelect"
                                            data-rule="required;"
                                            data-msg-required="请选择商品分类"
                                            data-ok=""
                                            data-target="#dictionaryId-msg">
                                        <option value="">请选择...</option>
                                        <c:forEach items="${sysGoodsType}" var="goodsType">
                                        <option value="${goodsType.id}">${goodsType.dicVal}</option>
                                        </c:forEach>
                                    </select>
                                    <label id="dictionaryId-msg"></label>
                                </td>
                            </tr>
                            <tr>
                                <th><span class="required">*</span><label for="name">商品价格：</label></th>
                                <td>
                                    <input maxlength="20" type="text" name="price" id="price" class="text w40"
                                           value="${goods.price}"
                                           data-rule="required;floats;"
                                           data-rule-floats="[/^\d+(\.\d{1,2})?$/,'请输入数字，或带小数点的数字']"
                                           data-msg-required="请输入商品价格"
                                           data-ok=""
                                           data-target="#price-msg">(万)
                                    <label id="price-msg"></label>
                                </td>
                            </tr>
                            <jsp:include page="goodsHouse.jsp">
                                <jsp:param name="house" value="true"/>
                            </jsp:include>
                            <tr>
                                <th><label for="tagNames">商品标签：</label></th>
                                <td>
                                    <input maxlength="100" type="text" name="tagNames" id="tagNames" class="text w500"
                                          >
                                    <label id="tagNames-msg"></label>
                                </td>
                            </tr>
                            <tr>
                                <th><label for="tagNames">商品图片：</label></th>
                                <td>
                                    <jsp:include page="/common/ui/uploadUI.jsp">
                                        <jsp:param name="goodsId" value=""/>
                                        <jsp:param name="uploadURL" value="${ctx}/my/seller/uploadGoodsImg.htm"/>
                                        <jsp:param name="deleteURL" value="${ctx}/goods/deleteGoodsImg.htm"/>
                                        <jsp:param name="changeType" value="${ctx}/goods/changeGoodsImgType.htm"/>
                                    </jsp:include>
                                </td>
                            </tr>
                            <tr>
                                <th><label >商品详情：</label></th>
                                <td>
                                    <jsp:include page="/common/ui/editorUI.jsp">
                                        <jsp:param name="mode" value="simple"/>
                                        <jsp:param name="name" value="content"/>
                                        <jsp:param name="content" value="${goods.content}"/>
                                        <jsp:param name="validate" value="yes"/>
                                        <jsp:param name="content" value=""/>
                                    </jsp:include>
                                </td>
                            </tr>
                            <c:if test="${goods==null}">
                            <tr>
                                <th><label>设置为模版：</label></th>
                                <td>
                                    <input type="checkbox" value="1" name="setTemplate">
                                    <span id="template_name" style="display: none;"><input type="text" name="templateName" class="text" placeholder="输入模板名称"></span>
                                </td>
                            </tr>
                            </c:if>
                            <tr class="tr-action">
                                <th>&nbsp;</th>
                                <td>
                                    <div id="form-edit-button">
                                        <input type="submit" class="button-action-ok" value="确定">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:goBack();" class="button-action-cancel"><span>返&nbsp;&nbsp;回</span></a>

                                    </div>
                                </td>
                            </tr>
                            <mytag:token/>
                            </tbody>
                        </table>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="fl u-1-5">
        <!--左边菜单 -->
        <%@include file="left.jsp" %>
    </div>
    <div class="hr-45"></div>


</div>
<script>
    function goBack(){
        var imgIds = $("input[name=plu_imageIds]").val();
        /*if(imgIds!=null && imgIds!=""){
            $.post("goods/deleteAllGoodsImg.htm",{ids:imgIds},function(data){
                if(data.status){

                }
            },"json");
        }*/
        location.href="${ctx}/my/seller/myGoods.htm";
    }

    $(function(){
        $("input[name=setTemplate]").click(function(){
            if($(this).is(":checked" )){
                $("#template_name").show();
            }else{
                $("#template_name").hide();
            }
        });
        <c:if test="${goods.dictionaryId!=null}">
        $("select[name=dictionaryId]").val("${goods.dictionaryId}");
        </c:if>
        <c:if test="${goods.publishState!=null}">
        $("select[name=publishState]").val("${goods.publishState}");
    </c:if>
    })
</script>
<!-- /主体 -->


<!-- 底部 -->
<%@include file="/common/footer.jsp" %>
<!-- /底部 -->

</body>
</html>
